unit QBStringTypes;

{$I QBuilderVerCtrl.inc}

interface

uses
  {$IFDEF VCL16}
    System.Types,
    Winapi.Windows,
    System.SysUtils,
    {$IFDEF USE_DEVEXPRESS}
      {$IFDEF EC_UNICODE}
        ecStrUtils,
        ecUnicode,
        ecRegistry
      {$ELSE}
        System.Classes
      {$ENDIF}
    {$ELSE}
      System.Classes
    {$ENDIF};
  {$ELSE}
    {$IFDEF VCL6}
      Types,
    {$ENDIF}
    Windows,
    SysUtils,
    {$IFDEF USE_DEVEXPRESS}
      {$IFDEF EC_UNICODE}
        ecStrUtils,
        ecUnicode,
        ecRegistry
      {$ELSE}
        Classes
      {$ENDIF}
    {$ELSE}
      Classes
    {$ENDIF};
  {$ENDIF}

type
  PaqbChar 			  = {$IFDEF EC_UNICODE} PecChar				  {$ELSE}	PChar				{$ENDIF};
  aqbChar 				= {$IFDEF EC_UNICODE} ecChar			  	{$ELSE} Char				{$ENDIF};
  aqbString 			= {$IFDEF EC_UNICODE} ecString		  	{$ELSE} string			{$ENDIF};
  TaqbStrings 		= {$IFDEF EC_UNICODE} TecStrings		  {$ELSE} TStrings		{$ENDIF};
  TaqbStringList  = {$IFDEF EC_UNICODE} TecStringList	  {$ELSE} TStringList	{$ENDIF};

function QBExtractQuotedStr( var Src: PaqbChar; Quote: aqbChar): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
function QBStrPCopy( Dest: PaqbChar; const Source: aqbString): PaqbChar;
{$IFDEF VCL9} inline; {$ENDIF}
function QBStrComp( S1, S2: PaqbChar): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
function QBDrawText(hDC: HDC; lpString: PaqbChar; nCount: Integer;
  var lpRect: TRect; uFormat: UINT): Integer;
{$IFDEF VCL9} inline; {$ENDIF}

function QBFormat(const FormatString: aqbString; const Args: array of const): aqbString;
// AnsiPos
function QBQuotedStr(const S: aqbString; Quote: aqbChar): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
function QBCompareText(const S1, S2: aqbString): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
function QBCompareStr(const S1, S2: aqbString): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
function QBStringReplace(const S, OldPattern, NewPattern: aqbString;
  Flags: TReplaceFlags): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
function QBUpperCase(const S: aqbString): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
function QBLowerCase(const S: aqbString): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}

procedure QBStrDispose( PStr: PaqbChar);
{$IFDEF VCL9} inline; {$ENDIF}

implementation

function QBExtractQuotedStr(var Src: PaqbChar; Quote: aqbChar): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideExtractQuotedStr(Src, Quote);
  {$ELSE}
  Result := AnsiExtractQuotedStr(Src, Quote);  // todo 2009
  {$ENDIF}
end;

function QBStrPCopy(Dest: PaqbChar; const Source: aqbString): PaqbChar;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := StrPCopyW(Dest, Source);
  {$ELSE}
  Result := StrPCopy(Dest, Source);
  {$ENDIF}
end;

function QBStrComp(S1, S2: PaqbChar): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := StrCompW(S1,S2);
  {$ELSE}
  Result := StrComp(S1,S2);
  {$ENDIF}
end;

function QBDrawText(hDC: HDC; lpString: PaqbChar; nCount: Integer;
  var lpRect: TRect; uFormat: UINT): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := DrawTextW(hDC, lpString, nCount, lpRect, uFormat);
  {$ELSE}
  Result := DrawText(hDC, lpString, nCount, lpRect, uFormat);
  {$ENDIF}
end;

function QBFormat(const FormatString: aqbString; const Args: array of const): aqbString;
begin
  {$IFDEF EC_UNICODE}
  WideFmtStr(Result, FormatString, Args);
  {$ELSE}
  Result := {$IFDEF VCL16}System.SysUtils{$ELSE}SysUtils{$ENDIF}.Format(FormatString, Args);
  {$ENDIF}
end;

function QBQuotedStr(const S: aqbString; Quote: aqbChar): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideQuotedStr( S, Quote);
  {$ELSE}
  Result := AnsiQuotedStr( S, Quote);
  {$ENDIF}
end;

function QBCompareText(const S1, S2: aqbString): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideCompareText( S1, S2);
  {$ELSE}
  Result := AnsiCompareText( S1, S2);
  {$ENDIF}
end;

function QBCompareStr(const S1, S2: aqbString): Integer;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideCompareStr( S1, S2);
  {$ELSE}
  Result := AnsiCompareStr( S1, S2);
  {$ENDIF}
end;

function QBStringReplace(const S, OldPattern, NewPattern: aqbString;
  Flags: TReplaceFlags): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := ReplaceStr( S, OldPattern, NewPattern, Flags);
  {$ELSE}
  Result := StringReplace( S, OldPattern, NewPattern, Flags);
  {$ENDIF}
end;

function QBUpperCase(const S: aqbString): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideUpperCase(S);
  {$ELSE}
  Result := AnsiUpperCase(S);  //todo 2009
  {$ENDIF}
end;

function QBLowerCase(const S: aqbString): aqbString;
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  Result := WideLowerCase(S);
  {$ELSE}
  Result := AnsiLowerCase(S);  // todo 2009
  {$ENDIF}
end;

procedure QBStrDispose(PStr: PaqbChar);
{$IFDEF VCL9} inline; {$ENDIF}
begin
  {$IFDEF EC_UNICODE}
  StrDisposeW(PStr);
  {$ELSE}
  StrDispose(PStr);
  {$ENDIF}
end;

end.

